package com.ajieee.merge.util;

import lombok.Getter;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionTemplate;

import java.util.function.Consumer;

/**
 * @author ajieee
 * @date 2025-08-09
 */
public class DBUtils {

	@Getter
	private static TransactionTemplate transactionTemplate;

	public static void init(TransactionTemplate transactionTemplate) {
		DBUtils.transactionTemplate = transactionTemplate;
	}

	private DBUtils() {
	}

	public static void transaction(Consumer<TransactionStatus> action) {
		getTransactionTemplate().executeWithoutResult(action);
	}

}
